<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0,
           maximum-scale=1.0, minimum-scale=1.0"/>
    <title>angular练习--apply的使用</title>

</head>
<body>
    <div ng-app="myApp">

        <div ng-controller="fristController" ng-click="show();">
            {{name}}
        </div>
    </div>
</body>
<script src="js/angular.js"></script>
<script type="text/javascript">
    /*
    * $apply实现文本倒计时的作用
    * */
    // 获取angular对象通过对象，操作controller
    var app= angular.module("myApp",[]);
    app.controller('fristController', function ($scope) {
        //此处复制的对象，在绑定的对象中可以获取
       setTimeout(function () {
           //在计时中实现文本倒计时
           $scope.$apply(function () {
               $scope.name="111";
           })
       },2000);
        $scope.name="不错哦,等待跳转...";

        $scope.show= function () {
            alert("这个地方哦");
        }
    })
</script>
</html>